
Imports ModuloAdministraciondeEnvios.PresentationLayer
Imports ModuloAdministraciondeEnvios.DataAccessLayer
Imports ModuloAdministraciondeEnvios.BusinessLogicLayer
Imports ModuloAdministraciondeEnvios.Entity

Imports System.Data.SqlClient
Imports System.Console
Imports System.IO.TextReader
Imports System.IO
Imports System.Net
Imports System.IO.Ports
Imports System.Text
Imports System.Xml
Imports System.IO.FileStream
Imports System.Collections
Imports System.Math
Imports System.Threading


Module DeclaracionesFunciones

    Public Comando As SqlCommand
    Public Adapter As SqlDataAdapter
    Public Ds As DataSet
    Public DataTable As DataTable
  
    Public StringConecta As String = "User Id=sa2;password=1234;Data Source=127.0.0.1\SQLEXPRESS;Initial Catalog=ENVIOS"
    Public StringComando As String
    Public Conecta As SqlConnection

    Public IdEnvio As Integer
    Public Fecha As Date
    Public Remitente As Integer
    Public Destinatario As Integer
    Public Movil As Integer
    Public TipoDePago As Integer
    Public TipoDeEnvio As Integer
    Public ImporteEnvio As Integer
    Public ImporteContrareembolso As Integer
    Public CantidadDePaquetes As Integer
    Public UltimoEstado As Integer

    Public ValorSeleccionado As Integer

    Public IdOrigen As Integer
    Public NombreOrigen As String
    Public DomicilioOrigen As String
    Public CUITOrigen As String
    Public LocalidadOrigen As String
    Public CPOrigen As String

    Public IdDestino As Integer
    Public NombreDestino As String
    Public DomicilioDestino As String
    Public CUITDestino As String
    Public LocalidadDestino As String
    Public CPDestino As String

    Public Dr As DataRow
    Public FrmEnvios As FrmEnvios
    Public Datos As DataSet

    Public Cliente As Cliente
    Public FrmClientes As FrmClientes

    Public ClienteID As Integer
    Public ClienteNombre As String
    Public ClienteDomicilio As String
    Public ClienteCUIT As String
    Public ClienteLocalidad As Integer
    Public Hora As TimeSpan
    Public Posicion As String
    Public Estado As Integer
    Public Pago As Decimal
    Public Observacion As String



    Function ValidarCUIT(ByVal CUIT As String) As Boolean

        Dim Suma As Integer
      
        If IsNumeric(CUIT) And CUIT.Length = 11 Then

            Suma = 0
            Suma += CInt(CUIT.Substring(0, 1)) * 5
            Suma += CInt(CUIT.Substring(1, 1)) * 4
            Suma += CInt(CUIT.Substring(2, 1)) * 3
            Suma += CInt(CUIT.Substring(3, 1)) * 2
            Suma += CInt(CUIT.Substring(4, 1)) * 7
            Suma += CInt(CUIT.Substring(5, 1)) * 6
            Suma += CInt(CUIT.Substring(6, 1)) * 5
            Suma += CInt(CUIT.Substring(7, 1)) * 4
            Suma += CInt(CUIT.Substring(8, 1)) * 3
            Suma += CInt(CUIT.Substring(9, 1)) * 2
            Suma += CInt(CUIT.Substring(10, 1)) * 1

            If Math.Round(Suma / 11, 0) = (Suma / 11) Then
                Return True
            End If
        Else
            Return False
        End If


    End Function

    Public Function ValidarDocumento(ByVal Documento As String) As Boolean

        If Documento.Length > 7 And IsNumeric(Documento) And Val(Documento) > 0 Then
            Return True
        Else
            Return False
        End If

    End Function







End Module
